// 金字塔的体积与指针
// A = 底面积
// h = 高度
// 体积 = Ah / 3

#include <iostream>
using namespace std;

int main() {
    double length;
    double width;
    double height;
    double volume;

    double* p_length = &length;
    double* p_width = &width;
    double* p_height = &height;
    double* p_volume = &volume;

    cout << "请输入金字塔的 长 和 宽: ";
    cin >> *p_length >> *p_width;

    cout << "很好,金字塔的高度是多少: ";
    cin >> *p_height;

    // 计算体积
    // 虽然间接访问符*的优先级比乘法符号*的优先级高
    // 但是加括号会让代码更清晰
    *p_volume = (*p_length) * (*p_width) * (*p_height) / 3.0;

    cout << "金字塔的底面为 " << length << " x " << width << "\n";
    cout << "高度为 " << height << "\n";
    cout << "体积为 " << volume << "\n";
}